const sm2 = require('miniprogram-sm-crypto').sm2
const sm4 = require('miniprogram-sm-crypto').sm4

// https://www.npmjs.com/package/sm-crypto

const cipherMode = 1
/**
 * SM2加密
 *
 * @param plainText
 * @param publicKey
 */
export function encryptSM2(plainText, publicKey) {
  return sm2.doEncrypt(plainText, publicKey, cipherMode)
}

/**
 * SM4解密
 *
 * @param encryptData
 * @param key
 */
export function decryptSM4(encryptData, key) {
  return sm4.decrypt(encryptData, key)
}